﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BrainMatch
{
    class BMUtility
    {
        public static string ColorToString(Color color)
        {
            return string.Format("{0},{1},{2}", color.R, color.G, color.B);
        }
        public static Color StringToColor(string valueStr)
        {
            string[] vs = valueStr.Split(',');
            if (vs.Length < 3) return Color.Black;
            return Color.FromArgb(int.Parse(vs[0]), int.Parse(vs[1]), int.Parse(vs[2]));
        }

        public static string IntsToString(int[] values)
        {
            if (values.Length <= 0) return "";
            if (values.Length == 1)
                return values[0].ToString();

            string r = values[0].ToString();
            for (int i = 1; i < values.Length; i++)
            {
                r += ",";
                r += values[i].ToString();
            }
            return r;
        }
        public static string DoublesToString(double[] values)
        {
            if (values.Length <= 0) return "";
            if (values.Length == 1)
                return values[0].ToString();

            string r = values[0].ToString();
            for (int i = 1; i < values.Length; i++)
            {
                r += ",";
                r += values[i].ToString();
            }
            return r;
        }

        public static int[] StringToInts(string valueStr)
        {
            string[] s = valueStr.Split(',');
            int[] values = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                values[i] = int.Parse(s[i]);
            }
            return values;
        }
        public static double[] StringToDoubles(string valueStr)
        {
            string[] s = valueStr.Split(',');
            double[] values = new double[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                values[i] = double.Parse(s[i]);
            }
            return values;
        }
    }
}
